#include "MaxProfitVisitor.h"

#include "StrategyNode.h"


USING_STOCK_NS

MaxProfitVisitor::MaxProfitVisitor(StockProfit profit, StrategyNode * node)
	: _profit(profit), _node(node)
{

}

void MaxProfitVisitor::Visit(StrategyNode * node)
{
	if (!node->GetChildren().empty())
	{
		return;
	}
	if (node->GetProfit() > _profit)
	{
		_profit = node->GetProfit();
		_node = node;
	}
}

StrategyNode * MaxProfitVisitor::GetStrategyNode()
{
	return _node;
}
